require.config({
    paths:{
        jq:"../libs/jquery.2.2.4",
        getJson:"../public/getJson",
        render:"../modules-list/render",
        setLocal:"../modules-list/setLocal"
    }
})
require(["jq","getJson","render","setLocal"],function(_,gj,r,sl){
    // console.log($)
    // console.log(gj);
    // console.log(r);
    console.log(sl);
    let goods=[]
    gj({
        url:"../data/data.json"
    }).then((res)=>{
        goods=JSON.parse(res)
        // console.log(res);
        r({
            data:JSON.parse(res),
            cont:$(".zuiniu"),
            page:1
        })
    })
    // 事件绑定
    $(".zuiniu").on("click",".add",function(){
        // console.log($(this).parent().parent().attr("index"));
        let id=$(this).parent().parent().attr("index")
        let sprice=$(this).prev().children("strong").html()-0
        // 存数据
        sl({id,sprice,num:1,flag:0})
    })
    document.querySelector(".flipr").onclick=function(){
        
        var flipn=this.parentElement.children[0].innerHTML;
        if(flipn>3)return
        this.parentElement.children[0].innerHTML = Number(flipn)+1;
        // console.log(goods)
        r({
            data:goods,
            cont:$(".zuiniu"),
            page:Number(flipn)+1
        })

    }

    document.querySelector(".flipl").onclick=function(){
        
        var flipn=this.parentElement.children[0].innerHTML;
        if(flipn<2)return
        this.parentElement.children[0].innerHTML = Number(flipn)-1;
        r({
            data:goods,
            cont:$(".zuiniu"),
            page:Number(flipn)-1
        })
    }
})
